﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using Mirkuz.Mapping;

namespace Mirkuz.TrailCompanion
{
    public class WaypointManager
    {
        public List<WayPoint> Waypoints=null;

        public WaypointManager()
        {
            Waypoints = new List<WayPoint>();
        }

        public void LoadFromKMLFile(string FileName)
        {           
            Mirkuz.Mapping.KMLReader r = new KMLReader(FileName);
            r.Parse();
            foreach (WayPoint p in r.Waypoints)
            {
                Waypoints.Add(p);
            }            
        }

        public void SaveToKMLFile(string FileName)
        {
            Mirkuz.Mapping.KMLCreator c = new Mirkuz.Mapping.KMLCreator(FileName);
            c.CreateKML();
            foreach (WayPoint p in Waypoints)
            {
                c.AddPoint(p);
            }
            c.CloseKML();
        }

        
    }
}
